<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
response.setHeader("Cache-Control", "no-store"); //HTTP 1.1
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
%>
<script type="text/javascript">
//<![CDATA[
require([],
	function(){
		if(typeof PasswordChange === "undefined" ){
			PasswordChange = {
				validator:function(){
					return dijit.byId("input_new_password_again").getValue() == dijit.byId("input_new_password").getValue();
				}
			};
			$kdom.appendDojoProp("cp_passwordchange_nav","content","<img class=\"icon_s_admin icon_s_admin_person\" src=\"${pageContext.request.contextPath}/assets/images/blank.gif\" /><span>"+ControlPanel._resource.changePassword+"</span>");
			dojo.byId("lbl_old_password").innerHTML = ControlPanel._resource.oldPsd;
			$kdom.appendDojoProp("input_old_password","promptMessage",ControlPanel._resource.passwordPromptMessage);
			$kdom.appendDojoProp("input_old_password","invalidMessage",ControlPanel._resource.passwordInvalidMessage);
			dojo.byId("lbl_new_password").innerHTML = ControlPanel._resource.newPsd;
			$kdom.appendDojoProp("input_new_password","promptMessage",ControlPanel._resource.passwordPromptMessage);
			$kdom.appendDojoProp("input_new_password","invalidMessage",ControlPanel._resource.passwordInvalidMessage);
			dojo.byId("lbl_new_password_again").innerHTML = ControlPanel._resource.newPsdAgain;
			$kdom.appendDojoProp("input_new_password_again","promptMessage",ControlPanel._resource.passwordSame);
			$kdom.appendDojoProp("input_new_password_again","invalidMessage",ControlPanel._resource.passwordNotSame);
			$kdom.appendDojoProp("btn_passwordchange_save","label",KppModule.commonResource.save);
		}
	});
//]]>
</script>
<span style="display:none">To solve IE7/8 script event tag problem.</span>
<div data-dojo-type="dijit/layout/BorderContainer" class="contentWrapper" style="margin:-2px;height:100%">
	<div id="cp_passwordchange_nav" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'" class="contentWrapperRight contentPaneNav" style="border:none;margin:-5px;padding:10px 0 10px 10px;background-color:transparent">
	</div>
	<div data-dojo-type="dijit/layout/ContentPane"  data-dojo-props="region:'top'" style="border:none;background-color:transparent;padding:0 4px;margin:-4px 0;">
		<div data-dojo-type="dijit/form/Form" style="margin:10px;" data-dojo-props="method:'post',encType:'multipart/form-data',id:'form_passwordchange_edit'" enctype="multipart/form-data" >
			<table cellspacing="10">
				<tr>
					<td>
						<label id="lbl_old_password">Old Password</label>
            		</td>
            		<td>
            			<input id="input_old_password" data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="name:'oldPsd',type:'password',required:true,regExp:'[0-9a-zA-Z_]{6,18}'"/>
            		</td>
            	</tr>
            	<tr>
            		<td>
            			<label id="lbl_new_password">New Password</label>
            		</td>
            		<td>
            			<input id="input_new_password" data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="name:'newPsd',type:'password',required:true,regExp:'[0-9a-zA-Z_]{6,18}'"/>
            		</td>
            	</tr>
            	<tr>
            		<td>
            			<label id="lbl_new_password_again">New Password Again</label>
            		</td>
            		<td>
            			<input id="input_new_password_again" data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="required:true,type:'password',
            			regExp:'[0-9a-zA-Z_]{6,18}',validator:PasswordChange.validator"/>
  					</td>
            	</tr>
			</table>
			<div data-dojo-type="dijit/form/Button" id="btn_passwordchange_save" style="padding-left:10px;" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconSave'">
			<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
				if(dijit.byId('input_new_password_again').validate() && dijit.byId('input_new_password').validate()){
					dojo.xhrPost({
						url:"../../adminuser/changepsd.do",
						handleAs:'json',
						headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},
						content:{"oldPsd":dojo.byId("input_old_password").value,"newPsd":dojo.byId("input_new_password").value},
						load:function(response){
							if(response.status=='success'){
								$ku.timeoutDialog(ControlPanel._resource.changePasswordSuccess,1500,KppModule.commonResource.hint,"width:200px;height:100px;");
							}else{
								var msg = response.message;
								if(msg==null || msg==''){
									msg = 'changePasswordFailed';
								}
								$ku.timeoutDialog("<font color='red'>"+ControlPanel._resource[msg]+"</div>",1500,KppModule.commonResource.error,"width:200px;height:100px;");
							}
						},
						error:function(){
							$ku.timeoutDialog("<font color='red'>"+ControlPanel._resource.changePasswordFailed+"</div>",1500,KppModule.commonResource.error,"width:200px;height:100px;");
						}
					});
				}
			</script>
		</div>
		</div>
	</div>
</div>